package com.ict.txmsv2.controller.system;

import com.ict.txmsv2.model.CheckUser;
import com.ict.txmsv2.model.MethodDescrition;
import com.ict.txmsv2.model.RespBean;
import com.ict.txmsv2.model.Role;
import com.ict.txmsv2.services.CheckService;
import com.ict.txmsv2.services.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author linzzz
 * @desc ...
 * @date 2020-12-16
 */
@RestController
@RequestMapping("/system/check")
public class SystemCheckController {

    @Autowired
    CheckService checkService;
    @Autowired
    RoleService roleService;

    @MethodDescrition("查看注册记录")
    @GetMapping("/")
    public List<CheckUser> getAllCheckUsers(){
        return checkService.getAllCheckUsers();
    }

    @MethodDescrition("获取所有角色")
    @GetMapping("/roles")
    public List<Role> getAllRoles(){
        return roleService.getAllRole();
    }

    @PutMapping("/{id}/{rids}")
    @MethodDescrition("通过审核")
    public RespBean changeUserToFormal(@PathVariable Integer id ,@PathVariable Integer[] rids){
        if (checkService.changeUserToFormal(id,rids) == 1){
            return RespBean.ok("恭喜你进入我室的人才库");
        }
        return RespBean.error("失败了...");
    }
}
